package test;

import org.xmap.ui.View;
import org.xmap.ui.ViewManager;
import org.xmap.ui.base.Window;
import org.xmap.ui.views.TextAreaView;

public class GuageView extends TextAreaView {

    private long startTime;

    public GuageView(View back) {
        super(back);
//        this.setBgColor(0x00ffff88);
        this.addText("这是个滚动条控件演示，选择“随机文本颜色”菜单设置滚动条控件的文本颜色为随机颜色，选择“随机边框颜色”设置滚动条控件的边框颜色为随机颜色，选择“边框模式”菜单下的子菜单可以显示或隐藏边框，选择“滚动条模式”菜单下的子菜单可以弹出带有单行或双行的提示信息的滚动条。");
        this.setTitleText("滚动条控件演示");
        this.addLeftMenu("随机文本颜色");
        this.addLeftMenu("随机边框颜色");
        this.addLeftMenu("边框模式", new String[]{"边框显示", "边框隐藏"});
        this.addLeftMenu("滚动条模式", new String[]{"单行模式", "双行模式" /*, "模式三", "模式四", "模式五"*/});
        this.setRightMenu("返回");
        this.startTime = System.currentTimeMillis();
    }

    public void update() {
        if (this.getShowGuage()) {
            if (System.currentTimeMillis() - this.startTime > 5000) {
                this.hideGuage();
            }
        }
    }

    public void commandEvent(String command, Window sender) {
        if (command.equals("随机文本颜色")) {
//            this.getMsgBox().setTextColor(XmapDemo.getRandomColor());
        } else if (command.equals("随机边框颜色")) {
//            this.getMsgBox().setLineColor(XmapDemo.getRandomColor());
        } else if (command.equals("边框显示")) {
//            this.getMsgBox().setDrawRect(true);
        } else if (command.equals("边框隐藏")) {
//            this.getMsgBox().setDrawRect(false);
        } else if (command.equals("单行模式")) {
            this.setGuageText("单行的提示信息", null, null, null);
            this.startTime = System.currentTimeMillis();
            this.showGuage();
        } else if (command.equals("双行模式")) {
            this.setGuageText("第一行提示信息", null, "第二行提示信息", null);
            this.startTime = System.currentTimeMillis();
            this.showGuage();
//        } else if (command.equals("模式三")) {
//            this.setGuageText("第一行文字", "第一行高亮", "第二行文字", null);
//            this.startTime = System.currentTimeMillis();
//            this.showGuage();
//        } else if (command.equals("模式四")) {
//            this.setGuageText("第一行文字", null, "第二行文字", null);
//            this.startTime = System.currentTimeMillis();
//            this.showGuage();
//        } else if (command.equals("模式五")) {
//            this.setGuageText("唯一的一行文字", null, null, null);
//            this.startTime = System.currentTimeMillis();
//            this.showGuage();
        } else if (command.equals("返回")) {
            ViewManager.instance.setView(this.back, View.ANIMATION_LEFT_TO_RIGHT);
        }
    }
}
